const rankingPartitions = require('../data/rankingPartitions')
const router = require('koa-router')()
const { fetchRankingById } = require('../api/index')
// 向api服务 添加排行榜路由模块
// 排行榜菜单
router.get('/partitions', (ctx, next) => {
    const resData = {
        code: 0,
        message: "0",
        data: rankingPartitions,
    }
    ctx.body = resData
})
// ranking/1   params  query
router.get('/:rId', async (ctx, next) => {
    const { rId } = ctx.params
    try {
        // 分层
        const data = await fetchRankingById(rId)
        ctx.body = data
    } catch(e) {
        next(e)
    }
    // ctx.body = rId
})
module.exports = router.routes()